//
//  GKZYUniversityDetailTopView.m
//  GKZYAid
//
//  Created by Tony Zhang on 16/3/12.
//  Copyright © 2016年 GKZYAid. All rights reserved.
//

#import "GKZYUniversityDetailTopView.h"
#import "MyDefine.h"
#import <UIImageView+WebCache.h>

@interface GKZYUniversityDetailTopView ()

@end


@implementation GKZYUniversityDetailTopView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
       
    }
    return self;
}


-(void)configureTheViewWithModel:(GKZYUniversityModel *)model{

     self.imageView = [[UIImageView alloc]initWithFrame:self.bounds];
    _imageView.image = [UIImage imageNamed:@"3"];
    [self addSubview:_imageView];
    
    UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(KmainScreenBoundsWidth*0.05, VIEWHEIGHT*0.3,VIEWWIDTH*0.3, VIEWWIDTH*0.3)];
    NSURL *url = [NSURL URLWithString:model.sch_logo];
    [image sd_setImageWithURL:url];
    image.layer.cornerRadius = VIEWWIDTH*0.15;
    image.layer.masksToBounds = YES;
    [self addSubview:image];
    
    UILabel *nameLab = [[UILabel alloc]initWithFrame:CGRectMake(VIEWWIDTH*0.4, VIEWHEIGHT*0.3, VIEWWIDTH*0.55, 40)];
    nameLab.backgroundColor = [UIColor clearColor];
    nameLab.textColor = [UIColor whiteColor];
    nameLab.font = [UIFont systemFontOfSize:22];
    nameLab.text = model.sch_name;
    [self addSubview:nameLab];
    
    UILabel *typeLab = [[UILabel alloc]initWithFrame:CGRectMake(VIEWWIDTH*0.4, CGRectGetMaxY(nameLab.frame)+VIEWWIDTH*0.02, 40, 20)];
    typeLab.backgroundColor = [UIColor whiteColor];
    typeLab.text = model.sch_type;
    typeLab.textAlignment = NSTextAlignmentCenter;
    typeLab.font = [UIFont systemFontOfSize:12];
    typeLab.layer.cornerRadius = 5;
    typeLab.layer.masksToBounds = YES;
    [self addSubview:typeLab];
    
    if (model.is_985) {
        UILabel *is_label = [[UILabel alloc]initWithFrame:CGRectMake(VIEWWIDTH*0.4+50, CGRectGetMinY(typeLab.frame), 40, 20)];
        is_label.backgroundColor = [UIColor whiteColor];
        is_label.text = @"985";
        is_label.font = [UIFont systemFontOfSize:12];
        is_label.layer.cornerRadius = 5;
        is_label.layer.masksToBounds = YES;
        is_label.textAlignment = NSTextAlignmentCenter;
        [self addSubview:is_label];
        
        if (model.is_211) {
            UILabel *is_211 = [[UILabel alloc]initWithFrame:CGRectMake(VIEWWIDTH*0.4+100, CGRectGetMinY(typeLab.frame), 40, 20)];
            is_211.backgroundColor = [UIColor whiteColor];
            is_211.text = @"211";
            is_211.font = [UIFont systemFontOfSize:12];
            is_211.layer.cornerRadius = 5;
            is_211.layer.masksToBounds = YES;
            is_211.textAlignment = NSTextAlignmentCenter;
            [self addSubview:is_211];
            
        }
    }else{
    
        if (model.is_211) {
            
            UILabel *is_label = [[UILabel alloc]initWithFrame:CGRectMake(VIEWWIDTH*0.4+50, CGRectGetMinY(typeLab.frame), 40, 20)];
            is_label.backgroundColor = [UIColor whiteColor];
            is_label.text = @"211";
            is_label.font = [UIFont systemFontOfSize:12];
            is_label.layer.cornerRadius = 5;
            is_label.layer.masksToBounds = YES;
            is_label.textAlignment = NSTextAlignmentCenter;
            [self addSubview:is_label];
        }
        
    }
    
    UIImageView *rankImage = [[UIImageView alloc]initWithFrame:CGRectMake(VIEWWIDTH*0.4, CGRectGetMaxY(typeLab.frame)+VIEWWIDTH*0.02, 22, 30)];
    rankImage.image = [UIImage imageNamed:@"order"];
    [self addSubview:rankImage];
    
    UILabel *markLab = [[UILabel alloc]init];
    NSString *string = @"学校综合排名：";
    markLab.font = [UIFont systemFontOfSize:12];
    CGSize size = [string sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:markLab.font,NSFontAttributeName, nil]];
    markLab.frame = CGRectMake(VIEWWIDTH*0.4+30, CGRectGetMinY(rankImage.frame)+10, size.width, 20);
    markLab.text = string;
    markLab.textColor = [UIColor whiteColor];
    [self addSubview:markLab];
    
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(markLab.frame)+2, CGRectGetMinY(rankImage.frame), 70, 30)];
    label.textColor = [UIColor whiteColor];
    label.font = [UIFont systemFontOfSize:25];
    label.text = [NSString stringWithFormat:@"%@",model.sch_rank_index];
    [self addSubview:label];

}






@end
